package threading;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: WHY
 * Date: 2022-09-15
 * Time: 19:49
 */
class   Singleton{
    //饿汉模式，实现单例模式
    private  static Singleton  instance=new Singleton();

    public static Singleton getInstance() {

        return instance;
    }
    private Singleton(){

    }
}
public class demo2 {

    public static void main(String[] args) {
        Singleton  instance=Singleton.getInstance();


    }
}
